#ifndef __MFILE_HPP__
#define __MFILE_HPP__
#include <string>
#include <sys/stat.h>
#include <fstream>

using namespace std;

enum{
	MF_SUCCESS,
	
	MF_ERR_COM_NULLPTR,
	MF_ERR_COM_NOTOPEN,
	MF_ERR_OP_CREATE,
	MF_ERR_OP_OPEN,

	MF_ERR_RD_FAILED,

	MF_ERR_WT_FAILED,

};
#define MF_OPT_TM_ACCESS 1
#define MF_OPT_TM_MODIFY 2
#define MF_OPT_TM_CHANGE 3
#define MF_OPT_TM_MAX 4

#define MF_OPT_WT_BEG 1
#define MF_OPT_WT_CUR 2
#define MF_OPT_RD_BEG 1
#define MF_OPT_RD_CUR 2
//#define MF_OPT_RD_END

class mFile{
public:
	string path_name;
	fstream f_ins;
public:
	~mFile();
	bool create( const char * filename_s );

	int open( const char * filename_s );
	bool is_open();
	void close();

	int read( char * buffer_p , int buf_size ,int type=MF_OPT_RD_CUR );
	int write( const char * content_p , int content_len , int type=MF_OPT_WT_CUR);
	
	bool rename ( const char * new_name_s );
	bool remove();
	
//	bool stat( struct stat *buf );
	/* set_time() is set the "last access" , "last modification" and "last status change" time */

protected:
	streampos rd_pos;
	streampos wt_pos;
protected:
	bool create_dir( const char * path_s );
//	int set_time( time_t time , int flag );	
};
#endif
